window.onload = function () {
  init(1);
};

//初始化订单数据，展示数据
async function init(pageNo) {
    let s = select();
    if (s == "不限"){
        s = "";
    }
    var order = await ajaxGet("/order/findByItem",{
        pageNo:pageNo,
        status: s,
        start: $("start").value,
        end:$("end").value
    });

    let str = "";
    for (let i = 0; i < order.list.length; i++) {
        var orderInfo = order.list[i];

        str += `<tr>
                    <td>${orderInfo.orderId}</td>
                    <td>${orderInfo.total}</td>
                    <td>${orderInfo.status}</td>
                    <td>${orderInfo.time}</td>
                    <td><a href="/html/manager/orderInfo.html?id=${orderInfo.orderId}">查看详情</a></td>
                </tr>`;
    }
    $("orderInfo").innerHTML = str;

    let a = "";
    for (let i = 1; i <= order.pages; i++) {
        a += `<a style="margin-left: 15px" href="javascript:init(${i})">${i}</a>`;
    }
    $("pageDiv").innerHTML = a;
}

function select() {
    let index = $("status").selectedIndex;
    let value = $("status").options[index].value;
    return value;
}

